import {
  mapGetters
} from 'vuex'
export default {
  onShow() {
    this.showCartCount()
  },
  computed: {
    ...mapGetters('cart', ['totals'])
  },
  methods: {
    //展示购物车中有多少个商品
    showCartCount() {
      uni.setTabBarBadge({
        index: 2,
        //text一定是字符串，不能是数字  0 移除数字
        text: this.totals == 0 ? (uni.removeTabBarBadge({
          index: 2
        })) : this.totals + ''
      })
    },
  }
}
